from model.item import Item
from sqlalchemy import Column, Integer, BigInteger, String, Float, DateTime, ForeignKey

from sqlalchemy.dialects.mysql import BIGINT, SMALLINT, TINYINT, YEAR

from sqlalchemy.orm import relationship

class Apartment(Item):
    __tablename__ =  'apartment'
    id = Column(BigInteger, ForeignKey('item.id'), primary_key = True)
    #description = Column(String(512))
    #year = Column(String(16))
    #type = Column(Integer)
    #unit = Column(String(32))
    
    level = Column(Integer)
    living_space = Column(Integer)
    floor = Column(Integer)
    n_rooms = Column(Integer)
    n_baths = Column(Integer)
    ac = Column(Integer)
    created = Column(DateTime)
        
    address_id = Column(Integer, ForeignKey('address.id'))
    address = relationship('Address', backref='apartments')
    
    __mapper_args__ = {
        'polymorphic_identity':'apartment',
    }
    
    def __init__(self, level, living_space=None, floor=None, n_rooms=None, n_baths=None, ac=None):

        #self.description = description
        #self.year = year
        #self.type = type
        #self.unit = unit
        
        self.level = level
        self.living_space = living_space
        self.floor = floor
        self.n_rooms = n_rooms
        self.n_baths = n_baths
        self.ac = ac


if __name__ == '__main__':
    # create table
    #db.drop_all()
    #db.create_all()
    pass